<?php

//use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CrearTablasGenerosTamanosColoresNombres extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up() {
        Schema::dropIfExists('colores');
        Schema::create('colores', function($table) {
            $table->increments('id');
            $table->string('tipo');
            //$table->timestamps();
        });
        Schema::dropIfExists('generos');
        Schema::create('generos', function($table) {
            $table->increments('id');
            $table->string('tipo');
            //$table->timestamps();
        });
        Schema::dropIfExists('tamanos');
        Schema::create('tamanos', function($table) {
            $table->increments('id');
            $table->string('tipo');
            //$table->timestamps();
        });
        
        Schema::dropIfExists('nombres');
        Schema::create('nombres', function($table) {
            $table->increments('id');
            $table->string('nombre');
            $table->integer('valoracion');
            $table->integer('color_id')->unsigned()
                    ->foreign('color_id')
                    ->references('id')->on('colores');
            $table->integer('genero_id')->unsigned()
                    ->foreign('genero_id')
                    ->references('id')->on('generos');
            $table->integer('tamano_id')->unsigned()
                    ->foreign('tamano_id')
                    ->references('id')->on('tamanos');
            //$table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down() {
        Schema::dropIfExists('nombres');
        Schema::dropIfExists('generos');
        Schema::dropIfExists('tamanos');
        Schema::dropIfExists('colores');
    }

}
